package com.yinhai.redis.cluster.event.filter;

import java.util.Arrays;

import junit.framework.Assert;

import com.yinhai.redis.cluster.event.Event;

public class OrEventFilter implements EventFilter {

	private EventFilter[] filters;
	
	public OrEventFilter(EventFilter... eventFilters){
		this.filters=eventFilters;
	}
	
	@Override
	public boolean match(Event event) {
		Assert.assertNotNull(filters);
		for(EventFilter f:filters){
			if(f.match(event)) return true;
		}
		return false;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + Arrays.hashCode(filters);
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		final OrEventFilter other = (OrEventFilter) obj;
		if (!Arrays.equals(filters, other.filters))
			return false;
		return true;
	}
	
	

}
